
package com.qdu.servlet;

import com.qdu.entity.Admin;
import com.qdu.service.AdminService;
import com.qdu.service.impl.AdminServiceImpl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author 24959
 */
@WebServlet("/als")
public class AdminLoginServlet extends HttpServlet{
    AdminService as=new AdminServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        int Ano=Integer.parseInt(req.getParameter("Ano"));
        String Apwd=req.getParameter("Apwd");
        Admin admin=as.validateLogin(Ano, Apwd);
        if(admin!=null){
        req.setAttribute("adminLogin", admin);
        req.setAttribute("Ano", Ano);
        req.getRequestDispatcher("/adminJsp.jsp").forward(req, resp);
        }else{
             resp.sendRedirect("fail.html");
        }
    }

   
    
}
